<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="Pragma" content="no-cache" />
		<title>我的易安</title>
		<%@ include file="/user_comm.jsp"%>
		<!-- publish_detail_ke.css  -->
		<link rel="stylesheet" href="<%=request.getContextPath()%>/css/publish_detail_ke.css" />
			
		<link href="<%=request.getContextPath()%>/css/prop.css"	type="text/css" rel="stylesheet" />
		<script src="<%=request.getContextPath()%>/js/barcode.js" language="JavaScript"></script>

	<script language="JavaScript">
	  function previewImage(vSpanId,fileId){
	  	var imgName=vSpanId;
	  	var imgId=$d(fileId).value;
	  	$(imgName).html('');   
		    var newPreview =$(imgName)[0];     
			var imgDiv = document.createElement("div");
			document.body.appendChild(imgDiv);
			imgDiv.style.width = "100%";
	        imgDiv.style.height = "100%";   
	        imgDiv.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod = scale)";      
	        imgDiv.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = imgId;
			newPreview.appendChild(imgDiv);	
	  }
		
		function selectOption(selId,selVal){
			var control=$d(selId);
			var options=control.options;
			control.options[0].selected=true;
			for(var i=0;i<options.length;i++){
				if(options[i].value==selVal){
					control.options[i].selected=true;
					break;
				}
			}
		}
		
		//----------------选择商品----------------
		function showProduct(){
			var retArr  = new Array();
			var winFeatures="dialogHeight:600px;dialogWidth:860px;edge:Raised;center:Yes;help:No;resizable:No;status:No;";
			var url="bproduct_listall.do";
			retArr = window.showModalDialog(url,"", winFeatures);
			if(retArr ==null || (!retArr)){
				return false;
			}else{
				var pid=retArr[0].toString();
				var params = {pid:pid};
				$.ajax({type: "POST",
			       url: "ajax_getProductTemplateById.do",
			       data: params,
			       async: true,   
			       success: function(result){
					 var product=result.product;
					 if(product != null){
					  	$d("productName").value=product.productName;
					  	$d("companyName").value=product.companyName;
					  	$("#productName").parents(".at_text").attr("class","at_text t_1_o").find("em").remove();
						$("#companyName").parents(".at_text").attr("class","at_text t_1_o").find("em").remove();

					  	$d("guige").value=product.guige;
					  	$d("pack").value=product.pack;
					  	selectOption("brandId",product.brandId);
					  	selectOption("type",product.type);
					 }
				  }
				},"json");

			   return true;
			}
		}
		
		function checkSubmit(){
			$('#barcode_add').submit();
			return true;
		}
		
		function pidChange(pidVal){
			var cid=$d("areaId2");
			cid.options.length = 0;
			if(pidVal=="-1")
				return;
			
			var params = {
						pid:pidVal
						};
			$.ajax({type: "POST",
			       url: "ajax_loadAreas.do",
			       data: params,
			       async: true,
			       success: function(result){
					 if(result.retcode=='0000'){
					    var areaList = result.areaList;
					    cid.options[0] = new Option('请选择','-1');
						for(var i=0;i<areaList.length;i++){
							var city=areaList[i];
							cid.options[i+1] = new Option(city.areaName,city.id);
						}	
					 }
				  }
				},"json");
		}
		
		function changeDiv(val){
			if(val==1){
				$d("div_1").style.display="block";
				$d("div_2").style.display="none";
				$d("div_seq1").style.display="block";
				$d("div_seq2").style.display="none";
			}else{
				$d("div_1").style.display="none";
				$d("div_2").style.display="block";
				$d("div_seq1").style.display="none";
				$d("div_seq2").style.display="block";
			}
			$d("inputtype").value=val;
		}
	</script>

	</head>
	<body>
		<%@ include file="/user_top.jsp"%>
		<link rel="stylesheet"
				href="<%=request.getContextPath()%>/css/cfb_color.css"
				type="text/css" />
		<div class="realCer">
			<!--导航-->
			<!--主体部分start-->
			<!-- <div class="realMain clearfix mt10">  -->
			<div class="realMain clearfix mt10 zffs wdzh">
				<%@ include file="/user_menu.jsp"%>
				<div class="realRight ml10 Buyer">
					<div class="mybox">
						<div class="mytit">
							条码激活
						</div>
						<div class="con Orbuy">
							<s:form name="formpage" action="barcode_add" namespace="/"
								method="POST" enctype="multipart/form-data">
								<div align="left">
									<%@ include file="/messages.jsp"%>
									<s:token>
									</s:token>
									<s:hidden name="busiBarcode.busiNo"
										value="%{#request.busiBarcode.busiNo}" />
									<s:hidden name="inputtype" id="inputtype" value="1" />
									
									<table class="basicInfor">
										<tr>
											<th>
												<label for="seqId">
													<font color="red">*</font>条码序列号：
												</label>
											</th>
											<td colspan="4">
											<div class="sub_top" id="div_1">
												<span class="at_tab_i">输入条码范围</span>
												<a
													href="#" onclick="changeDiv(2);"
													class="at_tab_i ">输入多个条码</a>
											</div>
											<div class="sub_top" id="div_2" style="display: none">
												<a
													href="#" onclick="changeDiv(1);"
													class="at_tab_i ">输入条码范围</a>
												<span class="at_tab_i">输入多个条码</span>
											</div>
											</td>
										</tr>
										<tr>
											<td></td>
											<td colspan="4">
												<div id="div_seq1">
												&nbsp;
												<span class="at_text t_1_d"><input
														name="busiBarcode.startSeq" id="startSeq" type="text" size="18" style="width: 130px;"
														maxlength="18" value="${busiBarcode.startSeq }" /> 
												</span>&nbsp;至
												<span class="at_text t_1_d"><input
														name="busiBarcode.endSeq" id="endSeq" type="text" size="18" style="width: 130px;"
														maxlength="18" value="${busiBarcode.endSeq }" /> 
													<span id="seqIdError"></span> </span>
												</div>
												
												<div id="div_seq2" style="display: none">
												&nbsp;
													<textarea name="busiBarcode.startSeq" cols="50"
														rows="5" style="width: 310px; height: 100px;" title="多个用,号分隔或换行"></textarea>多个用","号分隔或换行
												</div>
											</td>
										</tr>
										
										<tr>
											<th>
												<label for="pruductName">
													<font color="red">*</font>商品名称：
												</label>
											</th>
											<td class="fc9" colspan="4">
												&nbsp;
												<span class="at_text t_1_d"> <input
														id="productName" name="busiBarcode.productName" type="text" style="width: 305px;" 
														size="30" maxlength="40" value="${busiBarcode.productName }"/> 
												</span> &nbsp;
												<a target="_self" href="#"
													onclick="javascript:showProduct();">选择商品</a>
											</td>
										</tr>
										
										<tr>
											<th>
												<label id="lb_companyName" for="companyName">
													<font color="red">*</font>生产厂家：
												</label>
											</th>
											<td colspan="4">
												&nbsp;
												<span class="at_text t_1_d"><input id="companyName"
														name="busiBarcode.companyName"  size="30" style="width: 305px;" 
														type="text" maxlength="40" value="${busiBarcode.companyName}"
														title="*必填" /> </span>
											</td>
										</tr>
										
										<tr>
											<th>
												<label id="lb_carrierNo" for="batchNumber">
													批次号：
												</label>
											</th>
											<td>
												&nbsp;
												<span class="at_text t_1_d"><input id="batchNumber"
														name="busiBarcode.batchNumber" size="30"
														type="text" maxlength="40" value="${busiBarcode.batchNumber}"
														/> </span>
											</td>
											<td width="40"></td>
											<th>
												<label id="lb_carrierNo" for="madedate">
													生产日期：
												</label>
											</th>
											<td>
												&nbsp;
												<input id="madedate"
														name="busiBarcode.madeDate" size="33"
														value='<s:date name="#request.verifybookDto.toDate" format="yyyy-MM-dd" />'
														 class="Wdate" type="text" onFocus="WdatePicker()" 
														type="text" maxlength="10" value="${busiBarcode.madeDate}"
														/> 
														
											</td>
										</tr>
										<tr>
											<th>
												区域：
											</th>
											<td>
												&nbsp;
												<s:select name="busiBarcode.areaId" id="areaId" list="#request.areaList"
													onchange="pidChange(this.value);"
													headerKey="-1" headerValue="请选择" 
													style="width: 202px">
												</s:select>
											</td>
											<td width="40"></td>
											<th>
												销售商：
											</th>
											<td>
												&nbsp;
												<s:select name="busiBarcode.areaId2" id="areaId2" list="#request.areaList2"
													style="width: 202px">
												</s:select>
											</td>
										</tr>
										
										<tr>
											<th>
												品牌：
											</th>
											<td>
												&nbsp;
												<s:select name="busiBarcode.brandId" id="brandId" list="#request.brandList"
													headerKey="-1" headerValue="请选择" 
													style="width: 202px">
												</s:select>
											</td>
											<td width="40"></td>
											<th>
												<label id="lb_carrierNo" for="batchNumber">
													规格：
												</label>
											</th>
											<td>
												&nbsp;
												<span class="at_text t_1_d"><input id="guige" name="busiBarcode.guige"  size="30"
														type="text" maxlength="40" value="${busiBarcode.guige}"
													/> </span>
											</td>
										</tr>
										
										<tr>
											<th>
												包装方式：
											</th>
											<td>
												&nbsp;
												<span class="at_text t_1_d"><input id="pack"
														name="busiBarcode.pack" size="30"
														type="text" maxlength="40" value="${busiBarcode.pack}"
														/>
													</span>
											</td>
											<td width="40"></td>
											<th>
												产品类别：
											</th>
											<td>
												&nbsp;
												<select name="busiBarcode.type" id="type"
													style="width: 202px">
													<option value="-1">
														请选择
													</option>
													<option value="1">
														精装
													</option>
													<option value="2">
														一般装
													</option>
												</select>
											</td>
										</tr>
										 
										<tr>
											<td></td>
											<td>
												<a href="javascript:checkSubmit();" class="at_but b_1_y"
													id="reg_sub"><u></u>确认</a>
												<a href="javascript:javascript:history.go(-1);"
														class="at_but b_1_y" id="reg_sub"><u></u>取消</a>
														
											</td>
										</tr>
									</table>
								</div>

								<div id="div_contact" style="display: none">
										<table>
											<tr>
												<td width="200" valign="top">
													<div style="border: 1px solid #c5ddf6; padding: 5px;">
														<span id="spanGroups"> </span>
													</div>
												</td>
												<td width="650" valign="top">
													<!-- 联系人列表 start -->
													<div id="div_memberlist" style="display: block;">
														<table class="favorRwList mt5" id="tb_memberList">
														</table>
													</div>
													<!-- 联系人列表 end -->
												</td>
											</tr>
										</table>
								</div>
							</s:form>
						</div>
					</div>
					<div>
					</div>
					<!--主体部分end-->
				</div>
			</div>
		</div>
		<!--底部 start-->
		<%@ include file="/user_button.jsp"%>
		<script type="text/javascript">
			new barcode();
		</script>
		<!--底部end-->
	</body>
</html>

